ENMS Node API

Detailed Description

Data Structures

struct  EnmsService
 
struct  EnmsIndicationPolicy
 
struct  EnmsNode
 

Macro Definition Documentation

◆ ENMS_NODE_MAX_SERVICES

#define ENMS_NODE_MAX_SERVICES   10

Maximum number of services that can be registered.

◆ ENMS_DEFAULT_PORT

#define ENMS_DEFAULT_PORT   UINT16_C(0xf0b1)

Default UDP port number for the ENMS service.

Enumeration Type Documentation

◆ EnmsNodeResult

Possible ENMS Node function results.

Enumerator
ENMS_NODE_RESULT_OK 

Success.

ENMS_NODE_RESULT_INVALID_INPUT_ARGUMENT 

At least one of the input arguments to a function was invalid. The call was aborted.

ENMS_NODE_RESULT_FAILED_TO_REGISTER_UDP_SOCKET 

The service failed to register an UDP socket for communication. The service was aborted.

ENMS_NODE_RESULT_FAILED_TO_CREATE_TASK 

The service failed to create a task. The service was aborted.

ENMS_NODE_RESULT_FAILED_TO_RUN_TASK 

The service failed to run a task. The service was aborted.

ENMS_NODE_RESULT_FAILED_TO_REGISTER_SERVICE 

The service failed to register service.

ENMS_NODE_RESULT_SERVICE_ALREADY_REGISTERED 

The service failed to register service because it is already registered.

ENMS_NODE_RESULT_FAILED_TO_SEND_PACKET 

The service failed to send an UDP packet.

Function Documentation

◆ ENMS_NODE_Init()

EnmsNodeResult ENMS_NODE_Init ( EnmsNode enmsNode,
uint16_t  port,
const uint8_t  hwId[16],
const EnmsIndicationPolicy indicationPolicy 
)

Initializes the ENMS Node service.

This function initializes the ENMS Node service. It registers a UDP socket for communication with the ENMS BR service running typically in the border router. It also creates a task that is responsible for periodic sending of ENSM-BASIC-INFO messages.

Parameters
[in]enmsNodeENMS Node service instance
[in]portUDP port number over which the service will communicate, provide 0 to use default port value 0xF0B1
[in]hwIdhardware identifier
[in]indicationPolicyindication policy defining when and how often the indications should be sent (NULL to use default policy)
Return values
ENMS_NODE_RESULT_OKif the service was initialized successfully
ENMS_NODE_RESULT_INVALID_INPUT_ARGUMENTif at least one of the input arguments was invalid
ENMS_NODE_RESULT_FAILED_TO_REGISTER_UDP_SOCKETif the service failed to register a UDP socket
ENMS_NODE_RESULT_FAILED_TO_CREATE_TASKif the service failed to create a task

◆ ENMS_NODE_Deinit()

EnmsNodeResult ENMS_NODE_Deinit ( EnmsNode enmsNode)

Deinitializes the ENMS Node service

Parameters
[in]enmsNodeENMS Node service instance
Return values
ENMS_NODE_RESULT_OKif the service was deinitialized successfully
ENMS_NODE_RESULT_INVALID_INPUT_ARGUMENTif at least one of the input arguments was invalid

◆ ENMS_NODE_Start()

EnmsNodeResult ENMS_NODE_Start ( EnmsNode enmsNode)

Starts the ENMS Node service.

This function starts the ENMS Node service. It is typically called in reaction to the event that the node has joined a network. It schedules a task that periodically sends ENSM-BASIC-INFO messages.

Parameters
[in]enmsNodeENMS Node service instance
Return values
ENMS_NODE_RESULT_OKif the service was started successfully
ENMS_NODE_RESULT_INVALID_INPUT_ARGUMENTif at least one of the input arguments was invalid
ENMS_NODE_RESULT_FAILED_TO_RUN_TASKif the service was unable to run a task

◆ ENMS_NODE_Stop()

EnmsNodeResult ENMS_NODE_Stop ( EnmsNode enmsNode)

Stops the ENMS Node service.

This function stops the ENMS Node service. It is typically called in reaction to the event that the node has left a network. The service can be restarted by a call to ENMS_NODE_Start.

Parameters
[in]enmsNodeENMS Node service instance
Return values
ENMS_NODE_RESULT_OKif the service was stopped successfully
ENMS_NODE_RESULT_INVALID_INPUT_ARGUMENTif at least one of the input arguments was invalid

◆ ENMS_NODE_RegisterService()

EnmsNodeResult ENMS_NODE_RegisterService ( EnmsNode enmsNode,
const char *  serviceName,
uint8_t  serviceState 
)

Registers a service.

This function is used to tell the ENSM NODE service that other service runs in the node. Each service is described by:

  • a name (up to 15 characters + trailing '/0')
  • an unsigned integer (8 bit) that denotes the state of the service (0 usually means that the service is not active) Once the service is registered, its state can be changed by a call to ENMS_NODE_SetServiceState
Return values
ENMS_NODE_RESULT_OKif the service was registered
ENMS_NODE_RESULT_INVALID_INPUT_ARGUMENTif at least one of the input arguments was invalid
ENMS_NODE_RESULT_FAILED_TO_REGISTER_SERVICEif the service was not registered (probably exceeded the number of services that can be handled - see ENMS_NODE_MAX_SERVICES)

◆ ENMS_NODE_SetServiceState()

EnmsNodeResult ENMS_NODE_SetServiceState ( EnmsNode enmsNode,
const char *  serviceName,
uint8_t  serviceState 
)

Sets service state.

This function is used to update the state of a service, previously registered by a call to ENMS_NODE_RegisterService.

Return values
ENMS_NODE_RESULT_OKif the service state was updated
ENMS_NODE_RESULT_INVALID_INPUT_ARGUMENTif at least one of the input arguments was invalid
Go to Top